package com.burstly.jackson.util;

import com.burstly.jackson.Version;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class VersionUtil
{
  public static final String VERSION_FILE = "VERSION.txt";
  private static final Pattern VERSION_SEPARATOR = Pattern.compile("[-_./;:]");

  public static Version parseVersion(String paramString)
  {
    if (paramString == null);
    String[] arrayOfString;
    do
    {
      String str1;
      do
      {
        return null;
        str1 = paramString.trim();
      }
      while (str1.length() == 0);
      arrayOfString = VERSION_SEPARATOR.split(str1);
    }
    while (arrayOfString.length < 2);
    int i = parseVersionPart(arrayOfString[0]);
    int j = parseVersionPart(arrayOfString[1]);
    int k = arrayOfString.length;
    int m = 0;
    if (k > 2)
      m = parseVersionPart(arrayOfString[2]);
    int n = arrayOfString.length;
    String str2 = null;
    if (n > 3)
      str2 = arrayOfString[3];
    return new Version(i, j, m, str2);
  }

  protected static int parseVersionPart(String paramString)
  {
    String str = paramString.toString();
    int i = str.length();
    int j = 0;
    for (int k = 0; ; k++)
    {
      if (k >= i);
      int m;
      do
      {
        return j;
        m = str.charAt(k);
      }
      while ((m > 57) || (m < 48));
      j = j * 10 + (m - 48);
    }
  }

  public static Version versionFor(Class<?> paramClass)
  {
    Object localObject1 = null;
    try
    {
      InputStream localInputStream = paramClass.getResourceAsStream("VERSION.txt");
      localObject1 = null;
      if (localInputStream != null);
      try
      {
        Version localVersion = parseVersion(new BufferedReader(new InputStreamReader(localInputStream, "UTF-8")).readLine());
        localObject1 = localVersion;
      }
      finally
      {
        try
        {
          localInputStream.close();
          label47: if (localObject1 == null)
            localObject1 = Version.unknownVersion();
          return localObject1;
          localObject2 = finally;
          try
          {
            localInputStream.close();
            throw localObject2;
          }
          catch (IOException localIOException2)
          {
            throw new RuntimeException(localIOException2);
          }
        }
        catch (IOException localIOException3)
        {
          throw new RuntimeException(localIOException3);
        }
      }
    }
    catch (IOException localIOException1)
    {
      break label47;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.jackson.util.VersionUtil
 * JD-Core Version:    0.6.2
 */